import gensim.models.doc2vec
import sys
from classification import ModelManagement
from data import dataProcess
from vector import Vectorization
import fileConfig as Conf

model_path = Conf.model_path

def execute():
    sentence = str(sys.argv[1])
    # sentence = "这蛋糕真好吃"
    resultDataStream = dataProcess.dataLoadToList(Conf.train_file_path)
    cutSentence = dataProcess.sentenceCut(sentence, Conf.stop_file_path)
    vector = Vectorization()
    vectorSentence = vector.vectorizationWithModelOnSentence(cutSentence, model_path)
    modelM = ModelManagement()
    predict_data = [vectorSentence]
    model_conf = {"model_name": "SVM", "proportion": 0.3}
    model = gensim.models.doc2vec.Doc2Vec.load(model_path)
    result_vector_train_list = [model.docvecs[i] for i in range(len(model.docvecs))]
    result = modelM.modelPredict(predict_data=predict_data,
                                 train_data=result_vector_train_list,
                                 tag=resultDataStream[1],
                                 config=model_conf,
                                 if_save=False)
    print(result[0])

if __name__ == '__main__':
    execute()




    #传入评论参数
    #进行分词
    #利用向量化模型进行向量化
    #分模型分类